|
|
 |
|
|
|
|
' Copy the bitmap into picResult. BitBlt pic.hdc, 0, 0, wid, hgt, _
mem_dc, 0, 0, SRCCOPY
pic.Refresh
' Delete the device context and bitmap. DeleteDC mem_dc
DeleteObject hbmp
End Sub |
|
|
|
|
|
|
|
|
Example program Resize2 uses this code to resize images. Compare the program's speed and quality of the results with those of program Resize. |
|
|
|
|
|
|
|
|
At first, rotating an image may seem like a daunting task. If you look closely at the problem, however, you will find that it is very similar to the problem of image enlargement. In both cases, you have a function that maps pixels from a source image to a destination image. The rotation function is a bit more complex than the enlargement function, but the idea is similar. |
|
|
|
|
|
|
|
|
If you simply copy the source pixels to their corresponding rotated positions in the output image, some pixels will map to the same integral locations. That will leave gaps in the result. This is similar to the problem with enlarging an image, and you can solve it in a similar way. Map the pixels in the output image back to locations in the original image. Then use bilinear interpolation to calculate the output pixel's value. |
|
|
|
|
|
|
|
|
Example program Trans, shown in Figure 7.17, uses the image transformation framework described earlier in this chapter to rotate images. |
|
|
|
|
|
|
|
|
The only new part of the transformation process used by program Trans is the MapPixel subroutine that maps output pixels to input pixel positions. The first step in finding this mapping is understanding how the program rotates images. |
|
|
|
|
|
|
|
|
Figure 7.17
Rotating an image. |
|
|
|
|
|